package cn.com.lsy.product.lepao.service.impl;

import cn.com.lsy.product.lepao.model.mt.dao.MtEquipmentLogsMapper;
import cn.com.lsy.product.lepao.model.mt.entities.OpenDeviceListDto;
import cn.com.lsy.product.lepao.model.mt.entities.OpenDoorListDto;
import cn.com.lsy.product.lepao.model.mt.entities.UserEnterInfoDto;
import cn.com.lsy.product.lepao.model.mt.entities.UserEnterListDto;
import cn.com.lsy.product.lepao.service.IRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class RecordService implements IRecordService {

    @Autowired
    MtEquipmentLogsMapper mtEquipmentLogsMapper;

    @Override
    public List<OpenDoorListDto> selectOpenDoorListByPage(int start, int end, int storeId, String username, String startTime, String endTime) {

        Map<String, Object> where = new HashMap<String, Object>();
        where.put("start", start);
        where.put("end", end);
        where.put("storeId", storeId);
        where.put("username", username);
        where.put("startTime", startTime);
        where.put("endTime", endTime);

        return mtEquipmentLogsMapper.selectOpenDoorListByPage(where);
    }

    @Override
    public int selectOpenDoorListByCount(int storeId, String username, String startTime, String endTime) {

        Map<String, Object> where = new HashMap<String, Object>();
        where.put("storeId", storeId);
        where.put("username", username);
        where.put("startTime", startTime);
        where.put("endTime", endTime);

        return mtEquipmentLogsMapper.selectOpenDoorListByCount(where);
    }

    @Override
    public List<OpenDeviceListDto> selectOpenDeviceListByPage(int start, int end, int storeId, String username, String startTime, String endTime, int equipmentType) {

        Map<String, Object> where = new HashMap<String, Object>();
        where.put("start", start);
        where.put("end", end);
        where.put("storeId", storeId);
        where.put("username", username);
        where.put("startTime", startTime);
        where.put("endTime", endTime);
        where.put("equipmentType", equipmentType);

        return mtEquipmentLogsMapper.selectOpenDeviceListByPage(where);
    }

    @Override
    public int selectOpenDeviceListByCount(int storeId, String username, String startTime, String endTime, int equipmentType) {

        Map<String, Object> where = new HashMap<String, Object>();
        where.put("storeId", storeId);
        where.put("username", username);
        where.put("startTime", startTime);
        where.put("endTime", endTime);
        where.put("equipmentType", equipmentType);

        return mtEquipmentLogsMapper.selectOpenDeviceListByCount(where);
    }

    @Override
    public List<UserEnterListDto> selectUserEnterByPage(int start, int end, int storeId, String username, String startTime, String endTime) {

        Map<String, Object> where = new HashMap<String, Object>();
        where.put("start", start);
        where.put("end", end);
        where.put("storeId", storeId);
        where.put("username", username);
        where.put("startTime", startTime);
        where.put("endTime", endTime);

        return mtEquipmentLogsMapper.selectUserEnterByPage(where);
    }

    @Override
    public int selectUserEnterByCount(int storeId, String username, String startTime, String endTime) {

        Map<String, Object> where = new HashMap<String, Object>();
        where.put("storeId", storeId);
        where.put("username", username);
        where.put("startTime", startTime);
        where.put("endTime", endTime);

        return mtEquipmentLogsMapper.selectUserEnterByCount(where);
    }

    @Override
    public List<UserEnterInfoDto> selectUserEnterInfo(int userId, String startTime, String endTime) {

        Map<String, Object> where = new HashMap<String, Object>();
        where.put("userId", userId);
        where.put("startTime", startTime);
        where.put("endTime", endTime);

        return mtEquipmentLogsMapper.selectUserEnterInfo(where);
    }
}
